package chapter43;

import java.rmi.*;
import java.rmi.registry.*;

public class Server {

    private static final int PORT = 1099;
    private static final String BIND_NAME = "student";

    public static void main(String[] args) {
        try {
            // (1) rmiregistryを使用する場合
            //Registry registry = LocateRegistry.getRegistry();
            //registry.rebind(BIND_NAME, new DatabaseImpl());

            // (2) rmiregistryを使用しない場合
            Registry registry = LocateRegistry.createRegistry(PORT);
            registry.bind(BIND_NAME, new DatabaseImpl());

            System.out.println("StudentImpl server started");

        }
        catch (RemoteException e) {
            e.printStackTrace();
        }
        catch (AlreadyBoundException e) {
		 	e.printStackTrace();
		}
    }
}
